package com.achao.controller;

import org.springframework.web.client.RestTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
 * @Author: achao
 * @DateTime: 2022/10/14 17:32
 * @Description: TODO
 */
@RestController
@RequestMapping("/nacos")
public class DiscoveryController {

    @Resource
    private RestTemplate restTemplate;

    /**
     * 通过nacos-demo接口调用其他业务模块的接口
     * @param str
     * @return String
     */
    @GetMapping(value = "/echo/{str}")
    public String echo(@PathVariable String str) {
        return restTemplate.getForObject("http://user-service/user/name/" + str, String.class);
    }
}
